package com.zjgxzh.agentservice.controller;

import com.zjgxzh.agentservice.pojo.Agent;
import com.zjgxzh.agentservice.pojo.AgentTemplate;
import com.zjgxzh.agentservice.pojo.UserNamePost;
import com.zjgxzh.agentservice.service.AgentService;
import com.zjgxzh.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/agent")
public class AgentController {
    @Autowired
    AgentService agentService;

    @PostMapping("/list")
    public Result<List<Agent>> getAgents(@RequestBody UserNamePost username){
        //智能体列表的拉取
        //返回用户名下的所有智能体列表
        List<Agent> list = agentService.findAgentByUsername(username.getUsername());
        System.out.println(username+"\n"+list);
        return Result.success(list);
    }

    @PostMapping("/list_template")
    public Result<List<AgentTemplate>> getAgentTemplates(@RequestBody UserNamePost username){
        return Result.success(AgentTemplate.templates.values().stream().toList());
    }
}
